//
//  ArticalInfoController.swift
//  SmallParts
//
//  Created by 航汇聚 on 2019/11/6.
//  Copyright © 2019 BellaZhou. All rights reserved.
//

import UIKit
enum FunctionButtonForArticalInfoPage: Int {
    case share = 2000
    case collect
    case download
    case emailPass
}
class ArticalInfoController: UIViewController {
    @IBOutlet weak var tableView: UITableView!
    @IBOutlet weak var articalTitleLabel: UILabel!
    @IBOutlet weak var authorLabel: UILabel!
    @IBOutlet weak var organizeLabel: UILabel!
    @IBOutlet weak var resourceLabel: UILabel!
    @IBOutlet weak var keywordLabel: UILabel!
    @IBOutlet weak var typeLabel: UILabel!
    @IBAction func touchAction(_ sender: UIButton) {
        LoginViewController.sharedLoginScene.show(from: self)
        let tagValue: FunctionButtonForArticalInfoPage = FunctionButtonForArticalInfoPage(rawValue: sender.tag)!
        switch tagValue {
        case .share:
            break
        case .collect:
            break
        case .download:
            break
        case .emailPass:
            break
        }
    }
    var articalInfoObj: GuessFavoriteListItem? {
        didSet {
            if self.articalInfoObj != nil {
                self.configHeader(articalObj: self.articalInfoObj!)
                self.tableView.reloadData()
            }
        }
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.navigationBar.isHidden = false
        
    }
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        self.navigationController?.popViewController(animated: true)
    }
    func configHeader(articalObj: GuessFavoriteListItem) {
        self.articalTitleLabel.text = articalObj.title_c
        self.authorLabel.text = "作者:\(articalObj.author_e!.isEmpty ? "暂无" : articalObj.author_e!)"
        self.organizeLabel.text = "机构:\(articalObj.organs!.isEmpty ? "暂无" : articalObj.organs!)"
        self.resourceLabel.text = "出处:\(articalObj.range!.isEmpty ? "暂无" : articalObj.range!)"
        self.keywordLabel.text = "关键词:\(articalObj.keyword_c!.isEmpty ? "暂无" : articalObj.keyword_c!)"
        self.typeLabel.text = "类型:\(articalObj.classtypes!.isEmpty ? "暂无" : articalObj.classtypes!)"
    }
}
extension ArticalInfoController: UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "articalInfo", for: indexPath) as! ArticalInfoCell
        cell.articalContentLabel.text = self.articalInfoObj?.remark_c
        return cell
    }
}
class ArticalInfoCell: UITableViewCell {
    @IBOutlet weak var articalContentLabel: UILabel!
}
